package com.zhuiyun.pm.config;

import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class TokenError {

    public static void error(HttpServletResponse response, String warning, String code){
        response.setStatus(HttpStatus.OK.value());
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Type","application/json;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin","*");
        PrintWriter out = null;
        try {
            out = response.getWriter();
            out.append(JSONObject.toJSONString(CommonResult.error(code,warning)));
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
